/* -*- c++ -*- */

#ifndef _DEFS_H_
#define _DEFS_H_

#include <string.h>
#include <math.h>
#include <float.h>

// #if ( defined(_MSC_VER) && ( _MSC_VER >= 1500))
#ifdef _WIN32
#include <basetsd.h>
#endif

// typedef unsigned int _key_t;
typedef unsigned long long int _key_t;

#define MAXDOUBLE    DBL_MAX
#define MINDOUBLE    DBL_MIN
#ifndef MAXINT
#define MAXINT       INT_MAX
#endif
#ifndef MININT
#define MININT       INT_MIN
#endif
#ifndef MAXFLOAT
#define MAXFLOAT     FLT_MAX
#endif
#define MINFLOAT     FLT_MIN

#ifndef SQRT_3
#define SQRT_3       1.732050808
#endif 
#ifndef SQRT_3_2
#define SQRT_3_2     0.866025404
#endif 

#ifdef _WIN32

#ifndef strdup
#define strdup _strdup
#endif

#ifndef strcasecmp
#define strcasecmp  _stricmp
#endif

#endif // _WIN32

#define EPSILON              	1.5e-7
#define CASI_CERO            	1e-36
#define CASI_CERO_2          	1e-20
#define EPSILON_CMP          	1e-6
#define CASI_CERO_DOUBLE     	1e-306
#define CASI_CERO_DOUBLE_2   	1e-200
// const float SINGULAR_THRESHOLD = 1e-30f; // 1e-11f;
#define SINGULAR_THRESHOLD      1e-30f

#define MAIN_WINDOW_OFF_X       32 /*50*/
#define MAIN_WINDOW_OFF_Y       32 /*50*/
#define MAIN_WINDOW_WIDTH       1024
#define MAIN_WINDOW_HEIGHT      600 /*640*/

inline unsigned int next_highest_power_of_2( unsigned int v) {
  v--;
  v |= v >> 1;
  v |= v >> 2;
  v |= v >> 4;
  v |= v >> 8;
  v |= v >> 16;
  v++;
  return v;
}

inline unsigned int next_highest_cube( unsigned int n) {
  unsigned int cube = 0;
  for ( cube = 0; cube < n; cube++) {
    if ( cube * cube * cube > n)
      break;
  }
  return cube;
}

char *PonSeparadorDeMiles( char *buf, const size_t tam_max);

inline double inMB( size_t tam) {
  return ( double)tam / ( 1024.0 * 1024.0);
}

#endif // _DEFS_H_
